package com.liang.maogouyuyin.ui.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.liang.maogouyuyin.ui.fragment.TranslateFragment

class HomeFragmentAdapter(fragmentActivity: FragmentActivity): FragmentStateAdapter(fragmentActivity) {
    private val list = ArrayList<TranslateFragment>()

    override fun getItemCount(): Int {
        return 2
    }

    override fun createFragment(position: Int): Fragment {
        val fragment = TranslateFragment()
        if (position == 1)
            fragment.setDog(true)
        list.add(fragment)
        return fragment
    }

    fun getFragment(position: Int): TranslateFragment {
        return list[position]
    }
}